package com.example.test.dialogfactory;

import android.app.Application;
import android.content.Context;
import easier.app.x.starter.ActivityTaskManager;
import easier.log.logger.AndroidLogAdapter;
import easier.log.logger.Logger;

public class App extends Application {

    private ActivityTaskManager mTaskManager;

    public static void finishApp( Context context ) {

        Context app = context.getApplicationContext();
        if ( app instanceof App ) {

            ((App) app).mTaskManager.finishAll();
        }
    }

    public static String printActivity( Context context ) {

        Context app = context.getApplicationContext();
        if ( app instanceof App ) {
            return ((App) app).mTaskManager.getString();
        }
        return "";
    }

    @Override
    public void onCreate() {

        super.onCreate();

        Logger.addLogAdapter( new AndroidLogAdapter() );

        Logger.d( "app create" );

        mTaskManager = new ActivityTaskManager();
        mTaskManager.register( this );
    }

    @Override
    public void onLowMemory() {

        super.onLowMemory();
        Logger.d( "onLowMemory: " + this );
    }

    @Override
    public void onTrimMemory( int level ) {

        super.onTrimMemory( level );
        Logger.d( "onTrimMemory: " + level );
    }
}
